﻿
Imports System.Data
Imports System.Data.SqlClient

''' <summary>
''' 每日備注
''' </summary>
''' <remarks>
''' Author :huyang
''' Create date:2008/06/25
''' </remarks>
Public Class Frm_CSEveryRemark

    Implements IDServer.IDServer.IDServer

#Region "Variabled"

#Region "System Variabled Define"


    Public ActionHelp As IDServer.IDServer.ActionBtn = IDServer.IDServer.ActionBtn.ActionHelp

    Private WithEvents MainForm As Frm_MainForm

    Public Property SelectObject() As Frm_MainForm
        Get
            Return MainForm
        End Get
        Set(ByVal value As Frm_MainForm)
            MainForm = value
        End Set
    End Property

#End Region

#Region "user variabled define"

    ''' <summary>
    ''' 窗體是否加載
    ''' </summary>
    ''' <remarks></remarks>
    Private fLoadBool As Boolean = False

    Public FindBool As Boolean = True


#End Region

#End Region

#Region "Methods"

#Region "Initialize"

    Private Sub Initialize()

        Me.dtp_start.Text = ServerDate
        Me.dtp_end.Text = ServerDate
        Me.btnFind.Focus()
        Me.AddHandlers(New Control() {Panel1, GroupBox2})
        Dim cs As setControlEnabled = New setControlEnabled(New Control() {Me.GroupBox2})
        cs.SetControlsEnabled(False)
        Dim imeMode As clsIme = New clsIme()
        imeMode.AddHandler_ImeMode(New Control() {Panel1, GroupBox2})
    End Sub

#End Region

#Region "ExecFind"

    Private Function ReturnCaption() As Hashtable
        Dim hash As New Hashtable

        hash.Add("BoNum", "單號")
        hash.Add("fDateKey", "日期")
        hash.Add("Remark", "備注")

        Return hash
    End Function

    Private Function ReturnWhereExp() As String
        Dim sql As String = ""

        If Me.fLoadBool = False Then
            sql &= "  where 1<>1 "
        Else
            sql &= " where 1=1 "

            If Me.txt_BoNum.Text.Trim <> "" Then
                sql &= "  and BoNum='" & Me.txt_BoNum.Text.Trim & "' "
            End If

            sql &= "  and fDateKey>='" & Format(Me.dtp_start.Value, "yyyy-MM-dd") & "'"

            sql &= "  and fDateKey<='" & Format(Me.dtp_end.Value, "yyyy-MM-dd") & "'"

            If Me.txt_Remark.Text.Trim <> "" Then
                sql &= "  and Remark like '%" & Me.txt_Remark.Text.Trim & "%'"
            End If

        End If

        Return sql
    End Function

    Private Sub ExecFind(ByVal whereExp As String)
        Me.Cursor = Cursors.WaitCursor
        Dim sql As String = ""
        sql = "  select BoNum,fDateKey,Remark from CS_EveryRemark " & whereExp
        Dim Data As New DataTable
        Try
            Data = Exec(sql, E_ExecType.DataTable)
            Me.DGV_Master.DataSource = Data
            BindDataGridViewCaption(Me.DGV_Master, Me.ReturnCaption())
            FullFormatDataGridView(Me.DGV_Master, False, False)
            Me.DGV_Master.SelectionMode = DataGridViewSelectionMode.CellSelect
            Me.DGV_Master.AutoResizeColumns(System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells)
            Dim isFind As Boolean = Me.DGV_Master.RowCount > 0
            If Me.fLoadBool = True AndAlso FindBool = True Then
                Me.SetButton(ButtonType.Browse, IsFind)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            Me.Cursor = Cursors.Default
        End Try
    End Sub

#End Region

#Region "AddHandler Events"

    ''' <summary>
    ''' KeyDown Event
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub TextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        Try
            Select Case e.KeyCode
                Case Keys.Enter
                    If e.Shift = True Then
                        If TypeOf sender Is ComboBox Then
                            If CType(sender, ComboBox).DroppedDown = True Then
                                CType(sender, ComboBox).DroppedDown = False
                            End If
                        End If
                        Me.ProcessTabKey(False)
                        SendKeys.Send("{F4}")
                    Else
                        If TypeOf sender Is ComboBox Then
                            If CType(sender, ComboBox).DroppedDown = True Then
                                CType(sender, ComboBox).DroppedDown = False
                            End If
                        End If

                        Me.ProcessTabKey(True)
                        SendKeys.Send("{F4}")

                    End If
            End Select
        Catch ex As Exception
            MsgBox("TextBox_KeyDown:" & ex.Message & ex.StackTrace, MsgBoxStyle.Critical And MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    ''' <summary>
    ''' 添加自定義事件
    ''' </summary>
    ''' <param name="Pans"></param>
    ''' <remarks></remarks>
    Private Sub AddHandlers(ByVal Pans() As Control)
        Try
            For Each Pan As Control In Pans
                For Each Ctrl As Control In Pan.Controls
                    If TypeOf Ctrl Is TextBox _
                       OrElse TypeOf Ctrl Is ComboBox _
                       OrElse TypeOf Ctrl Is DateTimePicker Then
                        AddHandler Ctrl.KeyDown, AddressOf TextBox_KeyDown
                    End If
                Next
            Next
        Catch ex As Exception
            MsgBox("AddHandlers:" & ex.Message & ex.StackTrace, MsgBoxStyle.Critical And MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

#End Region

#Region "SetEnabled"

    ''' <summary>
    ''' 設置按鈕狀態
    ''' </summary>
    ''' <param name="type">操作類型</param>
    ''' <param name="IsFind">是否是流覽</param>
    ''' <remarks></remarks>
    Private Sub SetButton(ByVal type As ButtonType, ByVal IsFind As Boolean)
        Try

            Select Case type
                Case ButtonType.Add
                    With MainForm
                        .ToolStripAdd.Enabled = False
                        .ToolStripEdit.Enabled = False
                        .ToolStripDelete.Enabled = False
                        .ToolStripSave.Enabled = True
                        .ToolStripCancel.Enabled = True
                        .ToolStripFirst.Enabled = False
                        .ToolStripLast.Enabled = False
                        .ToolStripNext.Enabled = False
                        .ToolStripPrivous.Enabled = False
                        .ToolStripExport.Enabled = IsFind
                        .ToolStripImport.Enabled = True
                        .ToolStripPrint.Enabled = IsFind
                        .ToolStripFilter.Enabled = True

                    End With

                Case ButtonType.Browse
                    With MainForm
                        .ToolStripAdd.Enabled = True
                        .ToolStripEdit.Enabled = IsFind
                        .ToolStripDelete.Enabled = IsFind
                        .ToolStripSave.Enabled = False
                        .ToolStripCancel.Enabled = False
                        .ToolStripFirst.Enabled = IsFind
                        .ToolStripLast.Enabled = IsFind
                        .ToolStripNext.Enabled = IsFind
                        .ToolStripPrivous.Enabled = IsFind
                        .ToolStripExport.Enabled = IsFind
                        .ToolStripImport.Enabled = False
                        .ToolStripPrint.Enabled = IsFind
                        .ToolStripFilter.Enabled = True
                        .ToolStripCheck.Enabled = False
                        .ToolStripComplete.Enabled = False
                        .ToolStripUnCheck.Enabled = False
                    End With

                Case ButtonType.Cancel
                    With MainForm
                        .ToolStripAdd.Enabled = True
                        .ToolStripEdit.Enabled = IsFind
                        .ToolStripDelete.Enabled = IsFind
                        .ToolStripSave.Enabled = False
                        .ToolStripCancel.Enabled = False
                        .ToolStripFirst.Enabled = IsFind
                        .ToolStripLast.Enabled = IsFind
                        .ToolStripNext.Enabled = IsFind
                        .ToolStripPrivous.Enabled = IsFind
                        .ToolStripExport.Enabled = IsFind
                        .ToolStripImport.Enabled = True
                        .ToolStripPrint.Enabled = IsFind
                        .ToolStripFilter.Enabled = True

                    End With

                Case ButtonType.Edit
                    With MainForm
                        .ToolStripAdd.Enabled = False
                        .ToolStripEdit.Enabled = False
                        .ToolStripDelete.Enabled = False
                        .ToolStripSave.Enabled = True
                        .ToolStripCancel.Enabled = True
                        .ToolStripFirst.Enabled = False
                        .ToolStripLast.Enabled = False
                        .ToolStripNext.Enabled = False
                        .ToolStripPrivous.Enabled = False
                        .ToolStripExport.Enabled = IsFind
                        .ToolStripImport.Enabled = True
                        .ToolStripPrint.Enabled = IsFind
                        .ToolStripFilter.Enabled = True

                    End With

            End Select
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

#End Region

#Region "FillDetail"

    Private Sub FillDetail(ByVal BoNum As String)
        Try
            Dim dt As DataTable = DirectCast(Me.DGV_Master.DataSource, DataTable)
            Dim rows() As DataRow = dt.Select("BoNum='" & BoNum & "'")
            If rows.Length > 0 Then
                Me.txtBoNum.Text = rows(0).Item("BoNum") & ""
                Me.dtpfDateKey.Text = rows(0).Item("fDateKey") & ""
                Me.txtRemark.Text = rows(0).Item("Remark") & ""
            Else
                Me.txtBoNum.Text = ""
                Me.dtpfDateKey.Text = ServerDate
                Me.txtRemark.Text = ""
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Function UpdateDB(ByVal BoNum As String, ByVal fDateKey As String, ByVal Remark As String)
        Dim bSuccess As Boolean = False
        Try
            Dim dt As DataTable = DirectCast(Me.DGV_Master.DataSource, DataTable)
            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Then

                Dim Row As DataRow = dt.NewRow()
                Row("BoNum") = BoNum
                Row("fDateKey") = fDateKey
                Row("Remark") = Remark

                dt.Rows.Add(Row)

            Else

                Dim rows() As DataRow = dt.Select("BoNum='" & BoNum & "'")
                If rows.Length > 0 Then

                    rows(0).Item("BoNum") = BoNum
                    rows(0).Item("fDateKey") = fDateKey
                    rows(0).Item("Remark") = Remark

                End If
            End If

            dt.AcceptChanges()

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            bSuccess = False
        End Try

        Return bSuccess

    End Function

#End Region

#Region "SaveData"

    Private Function Validated1() As Boolean
        If Me.txtRemark.Text.Trim = "" Then
            MessageBox.Show("備注內容不能為空。", Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Me.txtRemark.Focus()
            Return False
        End If
        Return True
    End Function

    Private Function SaveData() As Boolean
        Dim sql As String = ""
        Dim BoNum As String = Me.txtBoNum.Text.Trim
        Dim fDateKey As String = Format(Me.dtpfDateKey.Value, "yyyy-MM-dd")
        Dim Remark As String = Replace_Text(Me.txtRemark.Text.Trim)
        Dim Person As String = PubUserName
        Dim cn As SqlConnection = GetConn()
        Dim cmd As SqlCommand = New SqlCommand()
        Dim tran As SqlTransaction = cn.BeginTransaction

        Try

            If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Then
                BoNum = Exec("ReturnBillNum 'CS_EveryRemark','BoNum','DG'", E_ExecType.ExecuteScalar)
                Me.txtBoNum.Text = BoNum

                sql &= " Insert Into CS_EveryRemark(BoNum,fDateKey,Remark,fOperatorPsn,fOperatorDate,fOperatorComputer)" & System.Environment.NewLine
                sql &= " values('" & BoNum & "','" & fDateKey & "','" & Remark & "','" & Person & "',Convert(nvarchar(19),getdate(),21),'" & My.Computer.Name & "') " & System.Environment.NewLine

            Else

                sql &= " Update CS_EveryRemark set fDateKey='" & fDateKey & "' ," & System.Environment.NewLine
                sql &= " Remark='" & Remark & "',fUpdatePsn='" & Person & "',fUpdateDate=Convert(nvarchar(19),Getdate(),21),fUpdateComputer='" & My.Computer.Name & "'" & System.Environment.NewLine
                sql &= " where BoNum='" & BoNum & "'" & System.Environment.NewLine()

            End If

            With cmd
                .CommandType = CommandType.Text
                .CommandText = sql
                .Connection = cn
                .Transaction = tran
                .ExecuteNonQuery()
            End With

            tran.Commit()
            MessageBox.Show(IIf(ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd, My.Resources.AddSuccess, My.resources.EditSuccess), Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            tran.Rollback()
            MessageBox.Show(IIf(ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd, My.Resources.ErrAdd, My.resources.ErrEdit), Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try

        UpdateDB(BoNum, fDateKey, Remark)

        Dim cs As setControlEnabled = New setControlEnabled(New Control() {Me.GroupBox2})
        cs.SetControlsEnabled(False)
        Me.SetButton(ButtonType.Browse, True)
        If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd Then
            If Me.DGV_Master.RowCount > 0 Then
                Me.DGV_Master.CurrentCell = Me.DGV_Master.Rows(Me.DGV_Master.RowCount - 1).Cells("BoNum")
            End If
        End If
        ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
        Return True
    End Function

#End Region

#End Region

#Region "Events"

#Region "Form Event"

    Private Sub Frm_CSEveryRemark_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.fLoadBool = False
        Me.Initialize()
        addColtrolEvents()
        Dim whereExp As String = Me.ReturnWhereExp()
        ExecFind(whereExp)
        Me.fLoadBool = True
    End Sub

#End Region

#Region "Button Event"

    Private Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click
        Dim whereExp As String = Me.ReturnWhereExp()
        ExecFind(whereExp)
    End Sub

#End Region

#Region "TabControl Event"

    Private Sub TabControl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TabControl1.KeyDown
        If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd OrElse ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
            If e.KeyCode = Keys.S Then
                If e.Control = True Then
                    MainForm.ToolStripSave.PerformClick()
                End If
            End If
        End If
    End Sub

    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        If Me.TabControl1.SelectedIndex = 1 Then
            Dim BoNum As String = ""
            If Not Me.DGV_Master.CurrentRow Is Nothing Then
                BoNum = Me.DGV_Master.CurrentRow.Cells("BoNum").Value & ""
            End If
            Me.FillDetail(BoNum)
        End If
    End Sub

    Private Sub TabControl1_Selecting(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl1.Selecting
        If ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd OrElse ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit Then
            e.Cancel = True
        End If
    End Sub



#End Region

#Region "DataGridView Event"

    Private Sub DGV_Master_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_Master.CellDoubleClick
        Me.TabControl1.SelectedIndex = 1
    End Sub

    Private Sub DGV_Master_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DGV_Master.RowPostPaint
        Try
            Dim Grid As DataGridView = DirectCast(sender, DataGridView)
            Dim SBrush As New SolidBrush(Grid.RowHeadersDefaultCellStyle.ForeColor)
            e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentCulture), e.InheritedRowStyle.Font, SBrush, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4)
            SBrush = Nothing
        Catch ex As Exception
            MessageBox.Show("DGV_Master_RowPostPaint:" & ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub


#End Region

#End Region

#Region "Interface"

    Public Function ActionAdd() As Boolean Implements IDServer.IDServer.IDServer.ActionAdd
        Try
            If AddEnable = False Then
                MessageBox.Show("對不起，您沒有新增權限", Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Function
            End If

            If Me.TabControl1.SelectedIndex = 0 Then
                Me.TabControl1.SelectedIndex = 1
            End If
            ActionHelp = IDServer.IDServer.ActionBtn.ActionAdd
            Me.FillDetail("")
            Me.SetButton(ButtonType.Add, False)
            Dim cs As setControlEnabled = New setControlEnabled(New Control() {Me.GroupBox2})
            cs.SetControlsEnabled(True)
            Me.txtBoNum.ReadOnly = True
            Me.txtRemark.Focus()

        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        Return True
    End Function

    Public Function ActionCancel() As Boolean Implements IDServer.IDServer.IDServer.ActionCancel
        Try
            ActionHelp = IDServer.IDServer.ActionBtn.ActionHelp
            Dim BoNum As String = ""
            Dim IsFind As Boolean = False
            If Not Me.DGV_Master.CurrentRow Is Nothing Then
                BoNum = Me.DGV_Master.CurrentRow.Cells("BoNum").Value & ""
                IsFind = True
            End If
            Me.FillDetail(BoNum)
            Dim cs As setControlEnabled = New setControlEnabled(New Control() {Me.GroupBox2})
            cs.SetControlsEnabled(False)
            Me.SetButton(ButtonType.Browse, IsFind)

        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        Return True
    End Function

    Public Function ActionDelete() As Boolean Implements IDServer.IDServer.IDServer.ActionDelete
        Try
            If DeleteEnable = False Then
                MessageBox.Show("對不起，您沒有刪除權限", Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Function
            End If

            If Me.DGV_Master.CurrentRow Is Nothing Then Return False
            Dim BoNum As String = Me.DGV_Master.CurrentRow.Cells("BoNum").Value & ""

            Dim sql As String = " delete CS_EveryRemark where BoNum='" & BoNum & "' "

            Exec(sql, E_ExecType.ExecuteNonQuery, True)

            Dim dt As DataTable = DirectCast(Me.DGV_Master.DataSource, DataTable)
            Dim Index As Integer = Me.DGV_Master.CurrentRow.Index

            Dim DRow() As DataRow = dt.Select("BoNum='" & BoNum & "'")
            If DRow.Length > 0 Then
                DRow(0).Delete()
            End If
            dt.AcceptChanges()

            MessageBox.Show(My.resources.DeleteSuccess, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)

            Index -= 1
            Me.DGV_Master.Refresh()
            If Me.DGV_Master.RowCount > 0 Then
                If Index >= 0 AndAlso Index < Me.DGV_Master.RowCount Then
                    Me.DGV_Master.CurrentCell = Me.DGV_Master.Rows(Index).Cells("BoNum")
                Else
                    Me.DGV_Master.CurrentCell = Me.DGV_Master.Rows(0).Cells("BoNum")
                End If
            End If
            Me.SetButton(ButtonType.Browse, Me.DGV_Master.RowCount > 0)

        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
        Return True
    End Function

    Public Function ActionEdit() As Boolean Implements IDServer.IDServer.IDServer.ActionEdit
        Try
            If EditEnable = False Then
                MessageBox.Show("對不起，您沒有修改權限", Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Function
            End If

            If Me.TabControl1.SelectedIndex = 0 Then
                Me.TabControl1.SelectedIndex = 1
            End If
            ActionHelp = IDServer.IDServer.ActionBtn.ActionEdit

            Me.SetButton(ButtonType.Edit, False)
            Dim cs As setControlEnabled = New setControlEnabled(New Control() {Me.GroupBox2})
            cs.SetControlsEnabled(True)
            Me.txtBoNum.ReadOnly = True
            Me.txtRemark.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message & ex.StackTrace, Msg.CompanyName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Function

    Public Function ActionExport() As Boolean Implements IDServer.IDServer.IDServer.ActionExport
        Try
            Dim Grid As DataGridView = Me.DGV_Master
            Dim ds As New DataSet
            Dim Dtab As DataTable
            Dtab = DirectCast(Grid.DataSource, DataTable).Copy
            Dtab.Columns.Remove("BoNum")
            Dtab.TableName = "Receive"
            Dim Hash As New Hashtable
            RemoveHideColumn(Grid, Dtab)
            Dim export As New ExcelExport()
            export.ExprotToExcel(Dtab, "每日備註")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Function

    Public Function ActionFilter() As Boolean Implements IDServer.IDServer.IDServer.ActionFilter

    End Function

    Public Function ActionGoFirst() As Boolean Implements IDServer.IDServer.IDServer.ActionGoFirst

    End Function

    Public Function ActionGoLast() As Boolean Implements IDServer.IDServer.IDServer.ActionGoLast

    End Function

    Public Function ActionGoNext() As Boolean Implements IDServer.IDServer.IDServer.ActionGoNext

    End Function

    Public Function ActionGoPrevious() As Boolean Implements IDServer.IDServer.IDServer.ActionGoPrevious

    End Function

    Public Function ActionImport() As Boolean Implements IDServer.IDServer.IDServer.ActionImport

    End Function

    Public Function ActionInitialize() As Boolean Implements IDServer.IDServer.IDServer.ActionInitialize

    End Function

    Public Function ActionPrint() As Boolean Implements IDServer.IDServer.IDServer.ActionPrint

    End Function

    Public Function ActionSave() As Boolean Implements IDServer.IDServer.IDServer.ActionSave
        If Me.Validated1() = False Then Return False
        Dim bSuccess = Me.SaveData()
        Return bSuccess
    End Function

    Public Function ActionSelect() As Boolean Implements IDServer.IDServer.IDServer.ActionSelect

    End Function

#End Region


    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub

    Private Sub addColtrolEvents()

        For Each col As Control In Me.GroupBox1.Controls
            If TypeOf col Is TextBox OrElse TypeOf col Is DateTimePicker Then
                AddHandler col.KeyDown, AddressOf Coltrol_KeyDown
            End If
        Next
    End Sub

    Private Sub Coltrol_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        If e.KeyCode = Keys.Enter Then
            Me.btnFind.PerformClick()
        End If
    End Sub


End Class
